<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" remarks="IE=edge">
    <title>社团信息管理</title>
    <#include "../../common/link.ftl">
    <link type="text/css" rel="stylesheet" href="/js/plugins/uploadifive/uploadifive.css" />
    <script type="text/javascript" src="/js/plugins/uploadifive/jquery.uploadifive.min.js"></script>
    <script src="/js/ckeditor/ckeditor.js"></script>
    <script>
        $(function () {
            //富文本框图片配置
            var ck = CKEDITOR.replace( 'remarks',{    // name = remarks 的textarea文本域   参数1：位置，参数2：上传的配置等
                filebrowserBrowseUrl: 'https://luowowo-12.oss-cn-shenzhen.aliyuncs.com',  // 预览路径，还没放到编辑器中     图片服务器，假装这里有
                filebrowserUploadUrl: '/uploadImg_ck.do' // 上传路径
            });

            // 日期插件 foundTime
            jeDate({
                dateCell:"#foundTime",
                format:"YYYY-MM-DD",
                isinitVal:false,  //是否初始化时间
                isTime:false, //是否开启时间选择
                minDate:"1990-09-19"
            })

            // 图片上传
            $('.imgBtn').uploadifive({
                'auto' : true,    // 自动发送图片上传请求
                'uploadScript' : '/uploadImg.do',  // 图片上传的请求路径
                buttonClass:"btn-link",    // 点击按钮的class
                'fileObjName' : 'pic',   // 文件上传的参数名
                'buttonText' : '浏览...',
                'fileType' : 'image',  // 上传文件类型
                'multi' : false,    // 是否上传多个
                'fileSizeLimit'   : 5242880,  // 每次上传限制的文件大小
                'removeCompleted' : true, //取消上传完成提示
                'uploadLimit' : 1,  // 上传个数限制
                //'queueSizeLimit'  : 10,   // 文件上传区域大小的限制
                'overrideEvents': ['onDialogClose', 'onError'],    //onDialogClose 取消自带的错误提示
                'onUploadComplete' : function(file, data) {  // 回调函数
                    $("#coverUrl").attr("src" ,data);  // data 约定是json格式的格式地址
                    $("#imgUrl").val(data);

                    console.log($("#imgUrl").val())
                },
                onFallback : function() {
                    $.messager.alert("温馨提示","该浏览器无法使用!");
                }
            });

            // 保存
            $("#btn_submit").click(function () {
                //异步提交时， 富文本框可能出问题
                $("#remarks").val(ck.getData())
                $("#editForm").ajaxSubmit(function (data) {
                    console.log(data);
                    if(data.code == 200){
                        window.location.href = "/association/list.do";
                    }else{
                        $.messager.alert("温馨提示", data.msg);
                    }
                })
            })

        })
    </script>
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <#include "../../common/navbar.ftl">
    <!--菜单回显-->
    <#assign currentMenu="association"/>
    <#include "../../common/menu.ftl">
    <div class="content-wrapper">
        <section class="content-header">
            <h1>社团新增/编辑</h1>
        </section>
        <section class="content">
            <div class="box">
                <form class="form-horizontal" action="/association/saveOrUpdate.do" method="post" id="editForm">
                    <input type="hidden" value="${(association.id)!}" name="id" id="id">
                    <div class="form-group" style="margin-top: 10px">
                        <label for="number" class="col-sm-2 control-label">社团编号：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="number" name="number" value="${(association.number)!}" placeholder="请输入社团编号">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="userName" class="col-sm-2 control-label">社团名称：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="username" name="username" value="${(association.username)!}" placeholder="请输入社团名称">
                        </div>
                    </div>

                    <#--<#if !association?? > <!--新增的时候需要显示密码输入框&ndash;&gt;-->
                     <div class="form-group">
                         <label for="password" class="col-sm-2 control-label">密码：</label>
                         <div class="col-sm-6">
                             <input type="password" class="form-control" id="password" name="password" placeholder="请输入密码"  value="${(association.password)!}">
                         </div>
                     </div>
                    <#--</#if>-->

                    <div class="form-group">
                        <label for="founder" class="col-sm-2 control-label">创始人：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="founder" name="founder" value="${(association.founder)!}" placeholder="请输入创始人">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="charact" class="col-sm-2 control-label">性质：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="charact" name="charact" value="${(association.charact)!}" placeholder="请输入性质">
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="person" class="col-sm-2 control-label">人数：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="person" name="person" value="${(association.person)!}" placeholder="请输入人数">
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="email" class="col-sm-2 control-label">邮箱：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="email" name="email" value="${(association.email)!}" placeholder="请输入邮箱">
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="foundTime" class="col-sm-2 control-label">成立时间：</label>
                        <div class="input-daterange col-sm-6">
                            <input type="text" class="input-sm form-control wicon" name="foundTime" id="foundTime"
                                   value="${(association.foundTime?string('yyyy-MM-dd'))!}" />
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="synopsis" class="col-sm-2 control-label">简介：</label>
                        <div class="col-sm-6">
                            <textarea  class="form-control" name="synopsis" >${(association.synopsis)!}</textarea>
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="dutyName" class="col-sm-2 control-label">社团负责人：</label>
                        <div class="col-sm-6">
                            <input type="hidden" value="${(association.dutyId)!}" name="dutyId" >
                            <input type="text" class="form-control" id="dutyName" name="dutyName" value="${(association.dutyName)!}" placeholder="请输入社团负责人名字">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="dutyMobile" class="col-sm-2 control-label">负责人电话：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="dutyMobile" name="dutyMobile" value="${(association.dutyMobile)!}" placeholder="请输入负责人电话">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="teacher" class="col-sm-2 control-label">指导老师：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="teacher" name="teacher" value="${(association.teacher)!}" placeholder="请输入指导老师名字">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="teacherMobile" class="col-sm-2 control-label">指导老师电话：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="teacherMobile" name="teacherMobile" value="${(association.teacherMobile)!}" placeholder="请输入指导老师电话">
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="isAgree" class="col-sm-2 control-label">审核状态：</label>
                        <div class="col-sm-6">
                            <select class="form-control" id="isAgree" name="isAgree">
                                <option value="-1">全部</option>
                                <option value="0">待审核</option>
                                <option value="1">审核通过</option>
                                <#if association??>
                                <option value="2">审核拒绝</option>
                                </#if>
                            </select>
                        </div>
                        <script>
                            $("#isAgree").val(${(association.isAgree)!});
                        </script>
                    </div>

                    <div class="form-group">
                        <label for="coverUrl" class="col-sm-2 control-label">图片：</label>
                        <div class="col-sm-8">
                            <input type="hidden"  class="form-control" id="imgUrl"  name="imgUrl" value="${(association.imgUrl)!}" >
                            <img src="${(association.imgUrl)!'/images/default.jpg'}" width="100px" id="coverUrl">
                            <button type="button" class="imgBtn">浏览</button>
                        </div>
                    </div>

                    <#if association??>
                    <div class="form-group">
                        <label for="reason" class="col-sm-2 control-label">拒绝理由：</label>
                        <div class="col-sm-6">
                            <textarea  class="form-control" name="reason" >${(association.reason)!}</textarea>
                        </div>
                    </div>
                    </#if>

                    <div class="form-group">
                        <label for="synopsis" class="col-sm-2 control-label">详细内容/备注：</label>
                        <div class="col-sm-6">
                            <textarea id="remarks" name="remarks" class="ckeditor">${(association.remarks)!}</textarea>
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-sm-offset-1 col-sm-6" style="margin-left: 35%">
                            <!--button如果是在form表单内部,不写type默认就是submit-->
                            <!-- 验证插件只支持submit按钮提交-->
                            <button id="btn_submit" type="button" class="btn btn-primary" style="margin-right: 20px; margin-bottom: 10px">保存</button>
                            <button type="reset" class="btn btn-danger" style="margin-right: 20px; margin-bottom: 10px">重置</button>
                        </div>
                    </div>
                </form>
            </div>
        </section>
    </div>
    <#include "../../common/footer.ftl">
</div>
</body>
</html>
